/*
 * =====================================================================================
 *
 *       Filename:  join.c
 *
 *    Description:  A pthread join example
 *
 *        Version:  1.0
 *        Created:  05/20/2011 05:37:18 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Deniz Kurucu (makkalot), makkalot [at] gmail.com
 *        Company:  
 *
 * =====================================================================================
 */

#include	<stdlib.h>
#include  <pthread.h>
#include  <string.h>
#include  <stdio.h>
#include  <unistd.h>


void* waitme (void *arg);
/* 
 *         Name:  main
 *  Description:  
 */
int main ( int argc, char *argv[] )
{
  int result;
  pthread_t tid;
  void *retval;
  
  if((result = pthread_create(&tid,NULL,waitme,(void*)5)) != 0){
       fprintf(stderr, "Failed to create attribute object: %s\n",strerror(result));
       exit(EXIT_FAILURE);
  }
  
  if((result = pthread_join(tid,&retval)) != 0){
    fprintf(stderr, "Failed to join the selected object: %s\n",strerror(result));
    exit(EXIT_FAILURE);
  }

  return EXIT_SUCCESS;
}	


/* 
 *         Name:  waitme
 *  Description:  
 */
void* waitme (void *arg)
{
  printf( "Start doing processing \n" );
  sleep((int)arg);
  printf( "End of doing processing \n" );
  return NULL; 
}		

